<?php
/**
@Project: 
@Page: 
@Path: 
@Notes: 
**/
class SHML_Ad
{

	public function ad_create($properties)
	{
		$p = $properties['attributes']['path'];
		$s = $properties['attributes']['site'];
		$w = $properties['attributes']['width'];
		$h = $properties['attributes']['height'];
		$t = rand(1,100000000);
		$p = (substr($p,0,1) != "/") ? "/" . $p : $p;
		$p = (substr($p,strlen($p)-1) == "/") ? substr($p,0,strlen($p)-1) : $p;
		
		$ad ='<script language="javascript" type="text/javascript">' . "\n";
		$ad .= 'document.write(\'<iframe id="dclk' . $t . '" src="" width="' . $w . '" height="' . $h . '" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0"';
		$ad .= ' scrolling="no" borderCOLOR="#000000">\');' . "\n";
		$ad .= 'if (navigator.userAgent.indexOf("Gecko")==-1) {' . "\n\t" .'document.write(\'<script language="javascript" src="http://ad.doubleclick.net/adj/trb.' . $s . $p;
		$ad .=';!category=net;pos=t;tile=1;dcopt=ist;ptype=sf;sz=' . $w . 'x' . $h . ';abr=!ie;ord=' .$t . '?" type="text/javascript"><\/script>\');' . "\n" . '}';
		$ad .= 'document.write(\'</iframe>\');' . "\n";
		$ad .= 'if (document.getElementById(\'dclk' . $t . '\')) {' . "\n\t" . 'document.getElementById(\'dclk' . $t . '\').src = \'http://ad.doubleclick.net/adi/trb.' . $s . $p;
		$ad .= ';!category=net;pos=t;tile=1;dcopt=ist;ptype=sf;sz=' . $w . 'x' . $h . ';ord=' . $t . '?\'; }' . "\n" . '</script>' . "\n";
		$ad .= '<noscript><a href="http://ad.doubleclick.net/jump/trb.' . $s . $p . ';sz=' . $w . 'x' . $h . ';ord=' . $t . '" target="_blank">';
		$ad .= '<img src="http://ad.doubleclick.net/ad/trb.' . $s . $p . ';sz=' . $w . 'x' . $h .';ord=' . $t . '" width="' . $w . '" height="' . $h . '" border="0" alt="" />';
		$ad .= '</a></noscript>';

		return $ad;
	}

}